package tests;

import junit.framework.TestCase;

import org.springframework.jdbc.datasource.DriverManagerDataSource;

import com.qsi.app.golf.db.GolfSpringDAO;
import com.qsi.app.golf.model.Golfer;

public class TestGolfSpringDAO extends TestCase {

    private GolfSpringDAO dao;

    public void setUp() {
    	dao = new GolfSpringDAO();
    	DriverManagerDataSource ds = new DriverManagerDataSource();
        ds.setDriverClassName("org.hsqldb.jdbcDriver");
        ds.setUrl("jdbc:hsqldb:db/test");
        ds.setUsername("sa");
        ds.setPassword("");
        dao.setDataSource(ds);
    }

    public void testGetGolfers() {
    	try {
    		dao.getGolfers();
    	} catch (Exception e) {
    		fail();
    	}
    }

    public void testCreateGolfer() {
        try {
        	Golfer golfer = new Golfer();
        	golfer.setFirstName("Testy");
        	golfer.setLastName("Tester");
        	dao.createGolfer(golfer);
        } catch (Exception e) {
        	fail();
        }
    }

}